package com.practice.springboot.Controller;

import com.practice.springboot.Repository.Jpa.StudentRepository;
import com.practice.springboot.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/jpa")
public class JpaHandler {
    @Autowired
    StudentRepository studentRepository;
    @GetMapping("/findById")
    public Student findBYId(Integer id){
        return studentRepository.findById(id).get();
    }
    @GetMapping("/findByName")
    public Student findByName(String name){
        return studentRepository.findByName(name);
    }
}
